#ifndef _IM_SERVER_AREA_INDEX_H_
#define _IM_SERVER_AREA_INDEX_H_

#include <stdint.h>
#include <string>
#include <set>
#include <boost/thread/shared_mutex.hpp>

namespace base {
class SimpleConnectionPool;
};

namespace imserver {

class AreaIndex {
public:
  static AreaIndex & Instance() {
    static AreaIndex index;
    return index;
  }

  int Reload();
  std::set<int64_t> Get(const std::string & city_code, const std::string & area_code, const std::string & quan_code) const;
private:
  AreaIndex();

  AreaIndex(const AreaIndex &);
  AreaIndex& operator=(const AreaIndex&);

  base::SimpleConnectionPool * db_conn_pool_;

  std::map<std::string, std::set<int64_t> > area_index_;
  mutable boost::shared_mutex mutex_;
};

}

#endif // _IM_SERVER_AREA_INDEX_H_
